import {
	RouterMount,
	createRouter
} from 'uni-simple-router';

const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,
	routes: [...ROUTES]
});

//全局路由前置守卫
router.beforeEach((to, from, next) => {
	//路由拦截	
	let rs = uni.getStorageSync('token')
	if (rs == 'yjr-token') {
		if (to.name == 'login') {
			next({
				name: 'index'
			})
		} else {
			next()
		}
	} else {
		if (to.name == 'login') {
			next()
		} else {
			next({
				name: 'login'
			})
		}
	}
});
// 全局路由后置守卫
router.afterEach((to, from) => {

})

export {
	router,
	RouterMount
}
